/*
 * All rights Reserved, Designed By DataDriver
 * Copyright:    DataDriver.Inc
 * Company:      Zhuo Wo Infomation Technology (ShangHai) CO.LTD
 */
package com.sun.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


@RestController
public class Consumer7001Controller {

    /**
     * RestTemplate是Spring提供的，本身是不支持负载均衡的
     * 要实现负载均衡可以使用Ribbon使用
     */

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/hello")
    public String test() {
        ResponseEntity entity = restTemplate.getForEntity("http://localhost:9001/test", String.class);
        String body = (String) entity.getBody();
        System.out.println(body);
        return body;
    }
}
